package com.yjd.pub.app.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import com.yjd.comm.base.enums.DbWREnums;
import com.yjd.comm.util.FrameUtil;
import org.springframework.stereotype.Service;

import com.yjd.comm.base.dao.IBaseDao;
import com.yjd.comm.base.service.impl.BaseServiceImpl;
import com.yjd.comm.app.model.PushRegidModel;
import com.yjd.comm.app.service.IPushRegidService;
import com.yjd.pub.app.dao.IPushRegidDao;

/**
 * <b>description</b>：推送服务业务实现<br>
 * <b>time</b>：2017-06-27 08:55:53 <br>
 * <b>author</b>：  yangchangyan@yijiedai.com
 */
@Service("pushRegidService")
public class PushRegidServiceImpl extends BaseServiceImpl implements IPushRegidService {

	/**
	 * 插入
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public PushRegidModel insert(PushRegidModel model) throws Exception {
		return this.pushRegidDao.insertModel(model, true);
	}

	/**
	 * 更新
	 * 
	 * @param model
	 * @return
	 * @throws Exception
	 */
	public int update(PushRegidModel model) throws Exception {
		return this.pushRegidDao.updateModel(model, true);
	}

	/**
	 * 根据id删除
	 * 
	 * @param id
	 * @return
	 * @throws Exception
	 */
	public int delete(long id) throws Exception {
		Map<Object, Object> paramMap = new HashMap<Object, Object>();
		paramMap.put("id", id);
		return this.pushRegidDao.deleteModel(paramMap, true);
	}

	@Override
	public int updateByMap(PushRegidModel model) throws Exception {
		Map<Object, Object> paramMap = FrameUtil.newHashMap();
		paramMap.put("id", model.getId());
		paramMap.put("user_id", model.getUser_id());
		paramMap.put("regid", model.getRegid());
		return this.pushRegidDao.updateByMap(paramMap, DbWREnums.WRITE.isWrite());
	}

	@Override
	public List<String> queryRegids(Map<String, Object> param) throws Exception {
		return this.pushRegidDao.queryRegids(param);
	}

	@Resource
	private IPushRegidDao pushRegidDao;

	@Override
	public IBaseDao getBaseDao() {
		return this.pushRegidDao;
	}

}
